import AppThemeMode from './AppThemeMode';
import { useDynamicValue as useDynamicVal } from './UseDarkMode';

interface IDynamicValue<T> {
	light: T
	dark: T
}

export class DynamicValue<T> implements IDynamicValue<T> {
	constructor(public readonly light: T, public readonly dark: T) {}
}

class GDynamicValue extends DynamicValue<any> {
  light: any;

  dark: any;

  constructor(light: any, dark: any) {
    super(light, dark);
    this.light = light;
    this.dark = dark;
  }

  get value() {
    return AppThemeMode.isDarkMode ? this.dark : this.light;
  }

  get darkValue() {
    return this.dark;
  }

  useDynamicValue() {
    // eslint-disable-next-line react-hooks/rules-of-hooks
    return useDynamicVal(this);
  }
}

export default GDynamicValue;
